package com.example.shopping;


import com.example.shopping.dao.ISpecificationDao;
import com.example.shopping.dao.ISpecificationOptionDao;

import com.example.shopping.pojo.Specification;
import com.example.shopping.pojo.SpecificationOption;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
class testSpecification {

    @Autowired
    private ISpecificationDao specificationDao;
    @Autowired
    private ISpecificationOptionDao specificationOptionDao;

    //测试全部查询
    @Test
    void selectSpecification() {
        List<Specification> specifications = specificationDao.selectSpecification();
        for (Specification s : specifications
        ) {
            System.out.println(s);

        }
    }

    //测试新增
    @Test
    public void insertSpecification() {
        Specification specification = new Specification(50, "李涛", 25);
        int i = specificationDao.insertSpecification(specification);
        int copy_id = specification.getCopyId();
        specificationOptionDao.insertSpecificationOption(new SpecificationOption("李涛2", copy_id, 2));
    }

    //测试模糊查询
    @Test
    void quertByLikespecName() {
        System.out.println(specificationDao.quertByLikespecName("李涛"));
    }

    //测试删除
    @Test
    void deleteSpecification() {
        Specification specification = specificationDao.selectByOneSpecification(13);
        int id = specification.getCopyId();
        System.out.println(id);
        int i = specificationDao.deleteSpecification(13);
        int id1 = specificationOptionDao.deleteSpecificationById(id);
    }

    //测试单条查询
    @Test
    void selectByOneSpecification() {
        System.out.println(specificationDao.selectByOneSpecification(17));
    }

}
